<template>
  <mt-header :fixed="fixed" :title="text || title">
    <slot slot="left" name="left" v-if="$slots.left"></slot>
    <mt-button slot="left" icon="back" @click="handleBack" v-else>返回</mt-button>
    <slot name="right" slot="right"></slot>
  </mt-header>
</template>
<script>
  export default {
    props: {
      text: {type: null},
      fixed: {type: Boolean, default: false},
      title: {type: null, default: ''}
    },
    name: 'header-back',
    data() {
      return {}
    },
    methods: {
      handleBack() {
        if (history.length <= 2) {
          this.$router.replace({name: 'home'})
        } else {
          this.$router.back()
        }
      }
    },
    created() {}
  }
</script>
